

// let lastTime = 1592884031193;
// console.log(new Date(lastTime).toLocaleTimeString());
//
// let targetTime = 1592852400000;
// console.log(new Date(targetTime));


class MNode{
    constructor(arr){
        this.arr = arr;

        this.children = [];
        this.edges = [];

        this.parent = null;
    }

    permutation(){
        if(this.arr.length < 2){
            return;
        }

        // 子节点
        this.arr.forEach((value,idx)=>{
            // 有几个元素 就是几叉树. 就有几条边
            let restArr = Array.from(this.arr).splice(idx,1);
            let child = new MNode(restArr);
            this.children.push(child);
            this.edges.push(value);
            child.parent = this;

            this.children.forEach(item=>{
                item.permutation();
            });
        });
    }

    getResult(){
        let ret = [];

    }

    static  buildMTree(samplerSet){
        let arr = Array.from(samplerSet);
        let root = new MNode(arr);
        root.permutation();
        return root;
    }
}



/**
 * 判断两个集合的元素是否一样
 * @param s1 {Set}
 * @param s2 {Set}
 * @return {boolean}
 */
function isSetEqual(s1,s2){
    if(s1.size !== s2.size){
        return false;
    }
    let hasDiff = false;
    s1.forEach(v=>{
        if(!s2.has(v)){
            hasDiff = true;
        }
    });
    return !hasDiff;
}


let samplerSet = new Set(['A','B']);
console.log(MNode.buildMTree(samplerSet));
